<?php

class Uuch_List{
    
    private $array;
    
    public function __construct(array $array) {
        $this->array = $array;
    }
    
    public static function create(array $array){
        return new Uuch_List($array);
    }

    public function frist($func){
        return new Uuch_List(Uuch_Util::first($this->array, $func));
    }
    
    public function select($func){
        return new Uuch_List(Uuch_Util::select($this->array, $func));
    }
    
    public function where($func){
        return new Uuch_List(Uuch_Util::where($this->array, $func));
    }
    
    public function sum($func){
        $sum = 0;
        foreach ($this->array as $item){
            $sum += $func($item);
        }
        return $sum;
    }
}